#include "GUIPanelButton.h"
#include "GameWorld.h"

GUIPanelButton::GUIPanelButton()
{
	m_referenceID = 0;
	m_drawRect = false;
	previous_update.x = 0;
	previous_update.y = 0;
	m_normalImage = "ignored_image";
	m_mouseOverImage = "ignored_image";
	m_imagesSet = false;

}

void GUIPanelButton::Update()
{
	this->ChangeX(this->GetX() + ClipPlane->GetX() - previous_update.x);
	this->ChangeY(this->GetY() + ClipPlane->GetY() - previous_update.y);

	previous_update.x = ClipPlane->GetX();
	previous_update.y = ClipPlane->GetY();
}

bool GUIPanelButton::GetBounds( int x, int y )
{
	x += ClipPlane->GetX();
	y += ClipPlane->GetY();

	if( ( x >= this->GetX() ) && ( x <= this->GetX() + this->GetWidth() ) &&
		( y >= this->GetY() ) && ( y <= this->GetY() + this->GetHeight() ) )
		return true;  // in bounds, return true
    
	return false; // not in bounds, return false
}

void GUIPanelButton::SetImages(const char* normal, const char* mouseOver)
{
	m_mouseOverImage = mouseOver;
	m_normalImage = normal;
	m_imagesSet = true;
}

void GUIPanelButton::SwapImages(bool setNormal)
{
	if(m_imagesSet)
	{
		if(setNormal)
			SetImageID(m_normalImage);
		else
			SetImageID(m_mouseOverImage);
	}
}